70002861 Attach a PDF as underlay Image

Article 70002861
Type Wish
Product Engine
Date Added 3/27/2026 12:00:00 AM
Fixed 12.0.02 (3/30/2026 12:00:00 AM)
Submitted by VectorDraw Team

Summary

Attach a PDF as underlay Image

Solution

In version 12.0.2 a PDF file can be imported as an underlay Image instead of vector graphics
VDF uses a high Resolution for display the PDF as Image
If you just want to have a PDF as an underlay on your drawing and do not need to edit it, it is recomented to add it as Underlay Image using the methods described as following
The underlay pdf image has the advantage of less memory usage and faster redraw with using a high Resolution image of pdf
To do this you can use onof the folowing methods:
1. Create a vdImageDef that reference an existing .pdf file
Create a vdImage object reference this vdImageDef

Example

string pdffilename;// an existing pdf file on your disk
int pageindex = 0;//we attach the first page of the pdf file
//Note it is better to set a Name to an ImageDefinition that contains the page number of the pdf that we want to display, in order to avoid the conflict when other pages are going to be added
vdImageDef imagedef = Images.Add(System.IO.Path.GetFileNameWithoutExtension(pdffilename) + "_" + (i + pageindex).ToString(), pdffilename);
imagedef.Transparency = Color.White;//set the transparency to white which is usually used by a pdf file
imagedef.ActiveFrame = pageindex;//the active frame of the pdf that we will attach

//create a new image tha rreference the previous image definition
VectorDraw.Professional.vdFigures.vdImage img = new VectorDraw.Professional.vdFigures.vdImage();
img.SetUnRegisterDocument(this);
img.setDocumentDefaults();
img.ImageDefinition = imagedef;
img.Display |= VdConstImg.VdImageTransparent;//set the dispay to transparent in order to transparency the white pdf background
img.ImageScale = 1.0d;
//set the image size equal to the selected pdf size in inches
if (img.ImageDefinition.PDFImageSize != null) img.ImageScale = img.ImageDefinition.PDFImageSize.x * scale;



If you want to get it later as VDF objects you can just call the explode method for the pdf image and add the exploded entities to your model

You can set the Transparency of the vdImageDef to System.Drawing.Color.White an the vdImage.DIsplay to VdImageShowImageTransparent. This will set the pdf white background transparent to your drawing
Note the PDF image transparency is working better when your drawing background is white because the pdf files are usually with white background

2.
Set the vdDocument.FileProperties.PDFImportProperties to contain the value of AsUnderlayImage and
Import the PDF as a single underlay image sized to the PDF page dimensions in inches.
When set, the PDF is not converted to vector entities but is instead embedded as an image.
This can be useful for large or complex PDFs that may not import correctly as vector data,
or when the visual fidelity of the PDF is more important than having editable vector entities.
The underlay PDF image has the advantage of lower memory usage and faster redraw.
You can control the display resolution of the underlay image using the vdDocument.FileProperties.PDFImportResolution property in predifine DPI values (72, 150, 300, 600).
Higher DPI values increase image fidelity but require more memory and processing time.
Default value is PDFImportResolutionEnum.DPI_300.

This flag is considered by the following methods and operations:

vdDocument.Open vdDocument.ImportFromFile (where PDF pages are imported into the document as separate layouts).

The vdFileProperties.DefaultPDFPage is used when importing a specific page as an underlay image. If DefaultPDFPage is less than zero, then all pages are imported as underlay images in separate layouts.

vdBlocks.AddFromFile

vdCommandAction.CmdPDFImport

vdCommandAction.cmdAttachAllPDFPagesEx

vdCommandAction.CmdInsert

vdCommandAction.CmdXref

Send comments on this topic.