2

I want to be able to add more default/custom paper sizes to a user's "DWG to PDF" PC3 file in AutoCAD, (or at least be able to read it) but the only way seems to be using the interface that AutoCAD provides. I know where the PC3 files are located, yet when I open one using something like Notepad, it seems to be compressed. I would like to be able to add to them using Visual Studio/VB.NET. There has to be a way to do this programmatically.

The file's header says: PIAFILEVERSION_2.0,PC3VER1,compress

braX
  • 11,506
  • 5
  • 20
  • 33

3 Answers3

2

Unfortunately we don't have public API to modify PC3 file.

Madhukar Moogala
  • 635
  • 1
  • 5
  • 11
1

there is a well solution for this changing the prefrence of the printer configuration path, and let the cad serach on your files like that. dont forget in your new pc3 file to deattach the pm file and ave a new one in the same folder

Public Sub Plot()
    Dim Ov As String, Nv As String
    Ov = CdApp.Preferences.Files.PrinterConfigPath '' this is the old location
    Nv = Application.StartupPath
    CdApp.Preferences.Files.PrinterConfigPath = Nv '' this is the new location
    Dim Lw(0 To 1) As Double, Up(0 To 1) As Double
    Lw(0) = -0.5 : Lw(1) = -0.5 : Up(0) = 1 : Up(1) = 1
    CdDoc.ActiveLayout.SetWindowToPlot(Lw, Up)
    CdDoc.ActiveLayout.CenterPlot = True
    'CdDoc.ActiveLayout.RefreshPlotDeviceInfo()
    CdDoc.ActiveLayout.ConfigName = "Boules JPG.pc3" ''this is the file that i make
    CdDoc.ActiveLayout.CanonicalMediaName = "UserDefinedRaster (1600.00 x 1600.00Pixels)"
    CdDoc.ActiveLayout.PlotRotation = AutoCAD.AcPlotRotation.ac0degrees
    CdDoc.ActiveLayout.PaperUnits = AutoCAD.AcPlotPaperUnits.acPixels
    CdDoc.ActiveLayout.PlotType = AutoCAD.AcPlotType.acWindow
    CdDoc.ActiveLayout.PlotWithLineweights = False
    CdDoc.ActiveLayout.PlotWithPlotStyles = False
    CdDoc.ActiveLayout.ScaleLineweights = False
    CdDoc.ActiveLayout.ShowPlotStyles = False
    CdDoc.ActiveLayout.StandardScale = AutoCAD.AcPlotScale.acScaleToFit
    CdDoc.ActiveLayout.UseStandardScale = True
    CdDoc.SetVariable("BACKGROUNDPLOT", 0)

    Dim fil_jpg As String = Application.StartupPath & "\" & "Boules2.jpg"
    
    CdDoc.Plot.PlotToFile(fil_jpg)
    CdApp.Preferences.Files.PrinterConfigPath = Ov '' return the value to old location

End Sub
braX
  • 11,506
  • 5
  • 20
  • 33
0

It seems that it is not possible, so I looked into other options for "printing" to a PDF file. Microsoft has an option in the Printer selection dropdown called Microsoft Print to PDF that can also be used to accomplish custom paper sizes without the need to modify a PC3 file. Custom paper sizes can be added to the underlying files programmatically, but it's a bit complex, involving reading the registry, and reading/writing to a system spool folder, with one of the files (XML file) needing to be saved in UTF8 No BOM format.

I do not wish to plagiarize someone else's work, nor do I want to recreate such a complex answer/solution, so instead I will provide this link to a Microsoft answers forum in case another person is interested in the solution:

Microsoft Print to PDF - Custom Paper Sizes

braX
  • 11,506
  • 5
  • 20
  • 33