70001382 Import of PDF files

Article 70001382
Type Wish
Product Engine
Version 7016
Date Added 8/15/2018
Fixed 8.8001.0.1 (10/4/2018)
Submitted by Shane Henson

Summary

Import of PDF files

Solution

Pdf open added in version 8.8001.0.1
By default calling the vdDocument.Open passing a pdf filename the vdDocument is fill one Layout for each pdf page.The First page is added to the Model Layout.Next pages create a new Layout with Page Number name.
We added a new form like below

This form can be used in order to help the user to select and place a page of a PDF file to the drawing. After pressing the Import button a cmdInsert command is being called in order for the user to place the page with the selected rotation and scale.
Then the Page is added to the Blocks of the Document and an insert were the user selected.

You can use the below method to call this form
summary>The Show method is used in order to show the Import PDF dialog. With this dialog the user can choose a page of a specific PDF and import it as block to the Document.
After that the cmdInbsert command is called so the user can place the page to the Document.
param name="Document">The Document object where the page is going to be inserted.
param name="Filename">The filename of the PDF file.
param name="ShowRotationScale">A boolean value representing if the textboxes of scale and rotation are going to be visible.
param name="InsertThePage">A boolean value representing if the cmdInsert command is going to be called after the user presses the Import button.
param name="SelectedPageBlockName">A string value to get the selected and created Block of the page selected.
returns>A DialogResult value that can be either OK or Cancel/Abort if the user did not add any page.
public static DialogResult Show(vdDocument Document , string Filename , bool ShowRotationScale , bool InsertThePage , out string SelectedPageBlockName)
This form can be directly called like this using c# code : frmPDFImport.Show(doc, @"C:\VectorDraw.pdf");

Note : This form is also being called at the InsertBlock dialog if the user selected to add a block from file and the filename is indeed a pdf file. After choosing so this form will appear to help the user select a specific page of the PDF to be inserted.

We also added a command to the CommandAction like below that will show this dialog so the use can pick one page
summary>This method is being used to insert a page of a pdf file in the Document.
param name="Filename">The filename of a pdf file OR "user",null so an openfiledialog will appear so the user picks the file.
returns>true if the pdf page was succesfully added to the Document.
public bool CmdPDFImport(object Filename)

And Also another one with more options
summary>Command so the user selects a pdf file and then is prompted to attach all the pages to the Document.
There are options for aligment(horizontal or vertical) , view(full or partial) , pages to export and distance between pages.
param name="Filename">The filename of the pdf OR null , "" so the user picks the file from a dialog.
param name="InsertionPoint">A gPoint object representing the Insertion point where the pages are going OR null , "user" so the user picks the point to the screen.
param name="Distance">A double value that indicates the distance between the pages OR null , "user" so the user is prompted.
param name="isHorizontal">A boolean value that indicates if the pages are going to be aligned horizontally or vertically OR null , "user" so the user is prompted.
param name="FullView">A boolean value that indicates if the preview of the pages is going to be full or partial while moving the cursor OR null , "user" so the user is prompted.
param name="Pages">A string value that can be either "All" or "1-3" indicating the pages to be added OR null , "user" so the user is prompted.
returns>true if the pages where inserted.
remarks>After the user clicks the selected position of the pages then for each page a block is created and added to the Document.
Then an Insert is being created that uses these blocks in order to show them.
code> doc.CommandAction.cmdAttachAllPDFPages(null, "user" , 1.0 ,false,true,"1-3");
public bool cmdAttachAllPDFPages(object Filename, object InsertionPoint, object Distance, object isHorizontal, object FullView, object Pages)

Also new static methods were added that can be used to internally open a PDF page. It is recommended to ask our support team on how to use these methods before doing so.

/// Imports specific pdf file name into the passed vdDocument object.
/// "document" object that will be filled with passed pdf file primitives objects.
/// "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 0 if succesed.
vdxFcnv.ConversionUtilities.openpdf(vdDocument document, string filename, int pageindex)

/// Create a preview Bitmap with passed width, height size in pixels where the pdf page is render on.
/// "document" The working vdDocument object.
/// "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
/// The page preview is center to the Bitmap keeping the pdf page size aspect.
/// Returns A Bitmap where the pdf page is render on
vdxFcnv.ConversionUtilities.PDFPageBitmapPreview(vdDocument document, string pdffilename, int pageid, int width, int height)


/// Returns the passed page size in hundrend os inches s as an array of two doubles.
/// "document" The working vdDocument object.
/// "pdffilename" A file with pdf extension
/// "index" Index number of the page. 0 for the first page.

vdxFcnv.ConversionUtilities.PDFGetPageSizeByIndex(vdDocument document, string pdffilename, int index)


/// Returns the number of pages of the passed pdf file name
/// "document" The working vdDocument object.
/// "pdffilename" A file with pdf extension

vdxFcnv.ConversionUtilities.PDFGetPageCount(vdDocument document, string pdffilename)

Send comments on this topic.