70002074 Export vdxFcnv PDF functionality to Wrapper

Article 70002074
Type Wish
Product Engine
Version 9002
Date Added 10/4/2021 12:00:00 AM
Fixed 9.9003.0.1 (10/4/2021 12:00:00 AM)
Submitted by jkdelta


Is it possible to export some of the vdxFcnv PDF functionality to Wrapper? Like the:    vdxFcnv.ConversionUtilities.openpdf(vdDocument document, string filename, int pageindex)    vdxFcnv.ConversionUtilities.PDFPageBitmapPreview(vdDocument document, string pdffilename, int pageid, int width, int height)    vdxFcnv.ConversionUtilities.PDFGetPageSizeByIndex(vdDocument document, string pdffilename, int index)    vdxFcnv.ConversionUtilities.PDFGetPageCount(vdDocument document, string pdffilename)


In version 9003.0.1 a new property ComInterops of vdDocument object was added
It returns an object that implements IvdDocumentComInterops interface with following methods:

int PDFNumPages(string fname);

fname:A file with pdf extension
Returns The number of pages of the passed pdf file name.

object PDFPageBitmapPreview(string pdffilename, int pageid, int width, int height);

summary: Create a preview Bitmap (as IPictureDisp) with passed width, height size in pixels where the pdf page is render on.
pdffilename:A file with pdf extension
pageid:Index number of the page. 0 for the first page.
width:Width for the created Bitmap in pixels
height:Height for the created Bitmap in pixels
remarks:The page preview is center to the Bitmap keeping the pdf page size aspect.

int PDFOpen(string filename, int pageindex);

summary: Imports specific pdf file name into the owner object.
filename:A filename with .pdf extension.
pageindex: A zero base index that represents an exisitng page of pass pdf file that will be added to passed document Model Layout.
If passed pageindex is -1 then all pages are open.Each is added into a deferent Layout in the passed Document.
The first page is added to Model Layout.
Other Pages are added to a new created Layout with Page number Name.
If passed pageindex is a single page number it added to the Model Layout
Each created Layout Printer is modified by the imported Pdf Page properties.
Returns an error code: 0 if succesed.

double[] PDFGetPageSizeByIndex(string pdffilename, int index);

summary: Returns the passed page size in hundrend of inches as an array of two doubles.
pdffilename:A file with pdf extension
index:Index number of the page. 0 for the first page.

VB6 Example:

Dim pic As IPictureDisp
Dim pagesize() As Double
Dim numpages As Integer
Dim fname As String
fname = "C:\Test\Building - 115.pdf"

Dim doc As VectorDraw_Professional.vdDocument
Set doc = VDraw1.ActiveDocument.WrapperObject

numpages = doc.ComInterops.PDFNumPages(fname)
Set pic = doc.ComInterops.PDFPageBitmapPreview(fname, 0, Me.Picture1.Width, Me.Picture1.Height)
If Not pic Is Nothing Then Me.Picture1.Picture = pic

Dim SizeP() as Double
Dim PageWidth As Double
Dim PageHeight As Double
   SizeP = doc.ComInterops.PDFGetPageSizeByIndex(fname, 1)
   PageWidth = SizeP(0) ' in hundreds of inches
   PageHeight = SizeP(1) ' in hundreds of inches
doc.ComInterops.PDFOpen fname, 0

doc.Redraw False

Under Delphi use a code like:

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, AxCtrls, OleCtrls, VDrawLib5_TLB, VDRawi5_tlb, VectorDraw_professional_TLB,
  StdCtrls, ActiveX,   mscorlib_TLB,  OleServer, StdVCL, System_Drawing_TLB, System_TLB,
  System_Windows_Forms_TLB,  VectorDraw_Actions_TLB, VectorDraw_Geometry_TLB,
  VectorDraw_Render_TLB, VectorDraw_Serialize_TLB, ExtCtrls;

procedure TForm1.Button1Click(Sender: TObject);
    doc: VectorDraw_Professional_tlb.ivdDocument;
    numpages: integer;
    filename: string;
    PageSize :  PSafeArray;
    pWidth : double;
    pHeight: double;
    rgIndices, LBound, HBound : Integer;
    PageSizeDA : array[0..1] of double;
    iPict : IPictureDisp;
  doc:=vdraw1.ActiveDocument.WrapperObject as VectorDraw_Professional_tlb.ivdDocument;
  numpages := doc.ComInterops.PDFNumPages(filename);
  form1.Caption:= 'Pages: ' + inttostr(numpages); // just for display
  SafeArrayGetLBound(PageSize, 1, LBound);
  SafeArrayGetUBound(PageSize, 1, HBound);
  for rgIndices := LBound to HBound do
    SafeArrayGetElement(PageSize, rgIndices, PageSizeDA[rgIndices]);
  pWidth:=PageSizeDA[0]; // in hundreds of inches
  pHeight:=PageSizeDA[1]; // in hundreds of inches
  form1.Caption:= 'PageSize: ' + floattostr(pWidth) + ' ' + floattostr(pHeight); // just for display
  iPict := doc.ComInterops.PDFPageBitmapPreview(filename,0,200,200) as IPictureDisp;
  SetOlePicture(Image1.Picture, iPict); //Image1 is a TImage added in the form


Send comments on this topic.