This code slient print on other printers,but on HP LaserJet Pro M402-M403 PCL 6 will popup printer select dialog.
gsapi_init_with_args(ptr, 12, new string[] {
"-empty",
"-dPrinted",
"-dBATCH",
"-dNOPAUSE",
"-dNOSAFER",
"-dNumCopies=1",
"-sDEVICE=mswinpr2",
"-dNOPROMPT",
"-dNoCancel",
"-sOutputFile="%printer%HP LaserJet Pro M402-M403 PCL 6",
"-f",
"D:\\report.pdf",
});
I want to auto select hp printer when print.
Related
I'm using vim and markdown as an alternative to obsidian. I'm doing the conversion from markdown to pdf using pandoc and I would like to resemble as much as possible the pdf output of obsidian since I like how it looks.
In general I could make both pdf looks almost the same, but, I got two problems, the first is that the inline math font is too big, the second that the spacing before and after an equation is different.
Here are two screenshots, the first one being the pandoc output, the second the obsidian output.
To style the pdf I'm using a custom latex snippet which I include with pandoc -H style.tex ... during the pdf compilation, with this I was able to change the spacing between the text and the sections title as well as other things like page margins, etc. But I didn't find anything related to the math nor the equation for a template
I've also tried writing the equation as $\small \vec{E}$ but didn't work.
I think it has to be a way of changing the spacing from the latex template, I know that pandoc is using the unicode-math package to convert the latex equations but didn't find nothing related on how to change the spacing for the equations nor the font size.
EDIT: the style.tex file
% page setup
\usepackage[a4paper,
top=2cm,
bottom=1.75cm,
left=1.75cm,
right=1.75cm]{geometry}
\usepackage{titlesec}
\usepackage{fontspec}
% inline code (backticks in md)
% taken from https://jdhao.github.io/2019/05/30/markdown2pdf_pandoc/
\linespread{1.15}
\definecolor{bgcolor}{HTML}{e0e0e0}
\let\oldtexttt\texttt
\renewcommand{\texttt}[1]{
\colorbox{bgcolor}{\oldtexttt{#1}}
}
% change boldfont bold to extrabold
% \setmainfont[
% BoldFont={Inter-ExtraBold}
% ]{Inter}
% change regular font to light font
% \setmainfont{Inter light}
\newfontfamily\titlefont{Inter}[
UprightFont = *-Regular,
BoldFont = *-ExtraBold,
]
\newfontfamily\sectionsfont{Inter}[
UprightFont = *-Regular,
BoldFont = *-SemiBold,
]
\titleformat{\section}
{\titlefont\huge\bfseries}
{}
{0em}
{}
\titleformat{\subsection}
{\sectionsfont\LARGE\bfseries}
{}
{0em}
{}
\titleformat{\subsubsection}
{\sectionsfont\Large\bfseries}
{}
{0em}
{}
\titleformat{\paragraph}
{\sectionsfont\large\bfseries}{\theparagraph}{1em}{}
\titlespacing*{\paragraph}
{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\titlespacing*{\subsubsection}
{0pt}{2.5ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\titleformat{\subparagraph}
{\normalfont\large\bfseries}{\theparagraph}{1em}{}
\titlespacing*{\subparagraph}
{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
EDIT2: this is the .tex output part showed in the screenshot
taken from:
pandoc --pdf-engine=xelatex file.md -o file.tex
eléctrica que efectúa el campo sobre la partícula. se puede calcular entonces como:
\[\frac{w_{a \rightarrow b}}{q_{0}} = - \int_{a}^{b} \vec{e} \cdot d\vec{l} = v_{b} - v_{a} = v_{ab}\]
donde \({q_{0}}\) es una pequeña carga puntual, \(v_{a}\) y \(v_{b}\) el potencial por unidad de carga de los puntos \(a\) y \(b\) respectivamente, \(\vec{e}\) el valor del campo eléctrico
I'm using this code to print items to pdf file using:
gfx.DrawString(mstrPrintData(mnumCurrentItemNumber) & "", **fntPrintFont**, brushBrushes, New XRect((numLeftMargin + mnumIndentFromLeftMargin(mnumCurrentItemNumber) + numAdjuster + gnumLeftShift) * gnumWidthScale, (mnumThisYPosition(mnumCurrentItemNumber) + mnumLastHeaderYPosition - mnumYPositionReBase) * gnumHeightScale, gPage.Width.Point, 0), XStringFormats.TopLeft)
where fntPrintFont has been previously set as:
fntPrintFont = New XFont("Name of new font", 15, FontStyle.Regular)
The routine prints some of the fonts I've tried, but not the new 'Daniel' handwriting font the customer wants. I installed the Daniel font correctly. Daniel font installed
When printing to dotmatrix printer, I noticed the texts in "Courier New" font are blurry/sponge when using GrapeCity's Document PDF.
To make sure it's not a printer driver issues, I used MS Word & set that text to "Courier New" with same font size as the one used in GrapeCity PDF. I then print it from MS Word, the text are crystal clear so I know the printer driver & Windows 10 printer setup is ok.
Does anyone know why it doesn't work too good in GrapeCity.Documents.PDF? How do we fix this script bug properly?
var pdfDocument = new GcPdfDocument(PdfEditor.GrapeCityLicense);
var pdfPage = pdfDocument.NewPage();
pdfPage.PaperKind = PaperKind.Legal;
pdfPage.Landscape = false;
var rectangleField = new RectangleF(10f, 20f, 200f, 10f);
var pdfGraphic = pdfPage.Graphics;
pdfGraphic.DrawString(
"Hello World! My car is 2008 Toyota LE Sedan 4 Camary. VIN is 4T1B346K88U780470",
new TextFormat()
{
FontName = "Courier New",
FontSize = 10.0f,
ForeColor = Color.Black,
Language = Language.English,
FontSizeInGraphicUnits = false,
FontStyle = FontStyle.Regular
},
rectangleField,
TextAlignment.Leading,
ParagraphAlignment.Near,
false
);
using (var pdfStream = new MemoryStream())
{
pdfDocument.Save(pdfStream);
pdfStream.Seek(0, SeekOrigin.Begin);
pdfBytes = pdfStream.ToArray();
}
Edited: Attached image as per commenter's request.
I have created pdf with wxhmltToPdf library by executing this command:
d:\wkhtmltox\bin\wkhtmltopdf.exe" -T 0 -B 0 -L 0 -R 0 --page-width 96 --page-height 65 --dpi 300 "http://myPage.html" test.pdf
The pdf is created and everything is fine just the problem is that pdf has 2 mm of white space at the bottom. I can't get rid of it, I guess it is a bug in library.
Even if content is split on more pages it is 2 mm white space at the bottom of each page (and I set all margins to 0).
So, I would like to open this pdf after it is created, cut 2 mm white space at the bottom(so cut first pdf page to 94 mm height from the top) and save as new pdf.
Could be done with C# or cmd.
I thought to use iTextSharp library in c#.
I can read pdf and save only first page to new pdf:
PdfReader reader = new PdfReader(Server.MapPath(P_InputStream3));
using (Document document = new Document())
{
using (PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(Server.MapPath(P_OutputStream), FileMode.Create)))
{
document.Open();
PdfContentByte cb = writer.DirectContent;
PdfImportedPage page = writer.GetImportedPage(reader, 1);
document.NewPage();
cb.AddTemplate(page, 0, 0);
document.Add(new Paragraph(DateTime.Now.ToShortDateString()));
document.Close();
}
}
But how can I copy only 94 mm of first page to new pdf?
I'm using Visual C++ 2005. I would like to use DDE to communicate with Adobe Acrobat, but I'm getting DDE connection failed.
Here's what I have so far:
HINSTANCE hRet;
/*Start the DDE server*/
hRet = ShellExecute(0, "open", "test.pdf", 0, 0, SW_SHOWNORMAL);
ASSERT((int)hRet >= 33);
/*Connect to server*/
HSZ hszApp, hszTopic;
char szApp[] = "acroview";
char szTopic[] = "control";
hszApp = DdeCreateStringHandle(dwIdInst, szApp, 0);
hszTopic = DdeCreateStringHandle(dwIdInst, szTopic, 0);
hConv = DdeConnect(dwIdInst, hszApp, hszTopic, NULL);
Adobe opens the pdf file fine, but when I call DdeConnect, it return NULL for hConv, telling "DDE Connection failed." Am I missing something?