ReportViewer prints one page letter size, but when I print it is in two pages - webforms

I'm using vs2017, C#, asp.net 4.6.1, and Rdlc 14.2 in a web.forms site
I have an one page report when I sent directly it to pdf, is in one page
ReportViewer1.DataBind();
Microsoft.Reporting.WebForms.Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string extension;
string deviceInfo = "<DeviceInfo>" +
" <OutputFormat>PDF</OutputFormat>" +
" <PageWidth>8.5in</PageWidth>" +
" <PageHeight>11in</PageHeight>" +
" <MarginTop>0.5in</MarginTop>" +
" <MarginLeft>0.25in</MarginLeft>" +
" <MarginRight>0.25in</MarginRight>" +
" <MarginBottom>1in</MarginBottom>" +
"</DeviceInfo>";
byte[] writeBinaryBytes = new byte[0];
writeBinaryBytes = ReportViewer1.LocalReport.Render
("Pdf", deviceInfo, out mimeType, out encoding, out extension,
out streamids, out warnings);
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.AddHeader
("content-disposition", "attachment; filename=" + nombreReporte+".pdf");
HttpContext.Current.Response.ContentType = "application/octet-stream";
HttpContext.Current.Response.BinaryWrite(writeBinaryBytes);
HttpContext.Current.Response.Flush();
When I view it in ReportViewer is in one page, but if I export it to pdf or print it, is in two pages… This is my code behind before printing
System.Drawing.Printing.PageSettings pg = new System.Drawing.Printing.PageSettings();
pg.Margins.Top = 50; //hundredths of an inch 0.5" * 100
pg.Margins.Left = 25; //hundredths of an inch 0.25" * 100
pg.Margins.Right = 25; //hundredths of an inch 0.25" * 100
pg.Margins.Bottom = 100; //hundredths of an inch 1" * 100
System.Drawing.Printing.PaperSize size = new PaperSize
{
RawKind = (int)PaperKind.Letter
//hundredths of an inch
, Width = 850 //hundredths of an inch 8.5" * 100
, Height = 1100 //hundredths of an inch 11" * 100
};
pg.PaperSize = size;
pg.Landscape = false;
//pg.PaperSource.RawKind = (int)PaperKind.A5;
ReportViewer1.SetPageSettings(pg);
ReportViewer1.LocalReport.Refresh();
This is the ReportViewer control in aspx page:
<rsweb:ReportViewer ID="ReportViewer1" runat="server"
ShowToolBar="true"
ShowFindControls ="false"
ShowCredentialPrompts="true"
ShowDocumentMapButton="true"
EnableEventValidation="fase"
AsyncRendering = "false"
width="100%" />
Any suggestions?
Thanks
rubenc

Well it turned out that the problem was that I had margins set inside the RDLC report, I just changed them to 0 and now its working.

Related

How to print barcodes containing letters

How to print codes
E27H, D18H, F28G, J16H, E19G, G29F, I19F, K09F, L18F
as barcodes from Visual FoxPro application.
I tried code below with Code 128 font but barcodes for those codes are created incorrectly:
StrTo128B('D18H') appears as D18 in printer bar code
StrTo128B('F28G') appears as 228
StrTo128B('J16H') appears as J16
It looks like if StrTo128B() result contains chr(81) and some other characters, those will not appear in output file:
Other bar codes are printed correctly. Use font script is not chacked:
* Converts a string to be printed with
* True Type Font "PF Barcode 128"
* Numerics and alphabetic (upper and lower case)
* If a character is not valid it is replaced by a space
* USE: _StrTo128B('Codigo 128 B')
* RETURNS: Character
* http://www.portalfox.com/index.php?name=News&file=article&sid=2600
FUNCTION StrTo128B(tcString)
LOCAL lcStart, lcStop, lcRet, lcCheck, ;
lnLong, lnI, lnCheckSum, lnAsc
lcStart = CHR(104 + 32)
lcStop = CHR(106 + 32)
lnCheckSum = ASC(lcStart) - 32
lcRet = tcString
lnLong = LEN(lcRet)
FOR lnI = 1 TO lnLong
lnAsc = ASC(SUBS(lcRet,lnI,1)) - 32
IF NOT BETWEEN(lnAsc,0,99)
lcRet = STUFF(lcRet,lnI,1,CHR(32))
lnAsc = ASC(SUBS(lcRet,lnI,1)) - 32
ENDIF
lnCheckSum = lnCheckSum + (lnAsc * lnI)
ENDFOR
lcCheck = CHR(MOD(lnCheckSum,103) + 32)
lcRet = lcStart + lcRet + lcCheck + lcStop
*--- Esto es para cambiar los espacios y caracteres invalidos
lcRet = STRTRAN(lcRet,CHR(32),CHR(232))
lcRet = STRTRAN(lcRet,CHR(127),CHR(192))
lcRet = STRTRAN(lcRet,CHR(128),CHR(193))
RETURN lcRet
ENDFUNC

Adding delay in Processing

so I am new to Processing and basically I am doing a program that when it runs, it opens a window with 4 different images, each of the image have description underneath. In the methods below, I created two random methods, one for the reviews number and the other for the review comments, I would like the comments to not be generated all the time for every film - more like popping up randomly, because it cause too much chaos trying to read them all. Also to check weather I can add arrays together of string and integer for the average value of the review number.
Below is the code, would appreciate your help. thanks.
import g4p_controls.*;
import ddf.minim.*;
PFont font;
PImage img1,img2; // background images for two different windows
PImage fimg1, fimg2, fimg3, fimg4, fimg5, fimg6; //images of movies
int rectX,rectY;
GButton btn;
GWindow window;
Minim minim;
AudioPlayer player;
String[] rev_film1 = {"The Best Wolverine Movie","Logan is another level","Disappointment","Such a sad farewell"}; //Logan
String[] rev_film2 = {"A scary movie that isn't scary.","Terrifyingly brilliant.","The perfect blend of comedy and horror","The IT Factor"}; //IT
String[] rev_film3 = {"Soul-less,Confused,Loud.","Devastatingly Disappointed","A technical masterpiece","A visual wonder that lacks depth"}; //Dunkirk
String[] rev_film4 = {"Disgrace", "Worst Star Wars movie", "TERRIBLE","A Betrayal to the Legacy"}; //Starwars
int[] rat_film1 = {9,8,2,2};
float r;
void setup()
{
size(1150,600,JAVA2D);
surface.setTitle(" - The Theatre of Dreams Database - ");
font = loadFont("BerlinSansFB-Reg-48.vlw");
img1 = loadImage("film2.jpg");
background(img1);
btn = new GButton(this,900,350,100,50, "Enter Website");
minim = new Minim(this);
player = minim.loadFile("sound.mp3");
player.play();
}
void draw()
{
fill(255);
textFont(font,32);
text("Welcome to", 850, 85);
text("The Theatre of Dreams", 760, 175);
text("Database", 870, 220);
}
void handleButtonEvents(GButton button, GEvent event)
{
if (button == btn && event == GEvent.CLICKED)
{
createWindow();
btn.setEnabled(false);
}
}
void createWindow() // creating new window with mouse click
{
window = GWindow.getWindow(this, " - Top 4 Movies in 2017 - ", 100, 50, 1150, 600, JAVA2D);
window.addDrawHandler(this, "windowDraw");
window.addOnCloseHandler(this, "windowClosing");
window.setActionOnClose(GWindow.CLOSE_WINDOW);
}
void windowDraw(PApplet app, GWinData data)
{
img2 = loadImage("film3.jpg");
app.background(img2);
app.text(" - Top 4 Movies in 2017 - ",440,85);
app.fill(255);
app.textFont(font,25);
fimg1 = loadImage("logan.jpg");
fimg2 = loadImage("it.jpg");
fimg3 = loadImage("dunkirk.jpg");
fimg4 = loadImage("starwars.jpg");
//////////Film 1 - LOGAN
app.image(fimg1,5,140,180,170);
app.text("Rating: 8.1 / 10",5,340); //fixed rating
app.text("Genres: Action | Drama", 5, 365);
app.text("| Sci-Fi | Thriller",5,390);
//Ratings that are constantly changing using the random function
for (int i = 0; i < 50; i++)
{
r = random(0, 6);
}
String user = "Ratings by users: " + nf(r,0,1) + " / 10";
app.text(user, 5,430);
// the random function of the comments
int index = int(random(rev_film1.length));
String user11 = "Reviews: " + "\n" + rev_film1[index];
app.text(user11, 5,460);
////////////////////Film 2 - IT
app.image(fimg2,960,360,180,170);
app.text("Rating: 7.6 / 10", 700,400);
app.text("Genres: Drama | Horror",700,430);
app.text("| Thriller",700,460);
//Ratings that are constantly changing using the random function
for (int i = 0; i < 50; i++)
{
r = random(5, 10);
}
String user2 = "Ratings by users: " + nf(r,0,1) + " / 10";
app.text(user2, 700,500);
int index2 = int(random(rev_film2.length)); // the random function of the comments
String user22 = "Reviews: " + "\n" + rev_film2[index2];
app.text(user22, 700,540);
/////////Film 3 - DUNKIRK
app.image(fimg3,320,250,180,170);
app.text("Rating: 8.1 / 10",320,445); //fixed rating
app.text("Genres: Action | Drama", 320, 470);
app.text("| History | Thriller | War",320,495);
//Ratings that are constantly changing using the random function
for (int i = 0; i < 50; i++)
{
r = random(0, 5);
}
String user3 = "Ratings by users: " + nf(r,0,1) + " / 10";
app.text(user3, 320,530);
int index3 = int(random(rev_film3.length)); // the random function of the comments
String user33 = "Reviews: " + "\n" + rev_film3[index3];
app.text(user33, 320,560);
/////////////Film 4 - STAR WARS
app.image(fimg4,570,120,180,170);
app.text("Rating: 7.6 / 10", 760,140); //fixed rating
app.text("Genres: Action | Adventure | Fantasy ", 760,168);
app.text("| Sci-Fi", 760,195);
//Ratings that are constantly changing using the random function
for (int i = 0; i < 50; i++)
{
r = random(0, 2);
}
String user4 = "Ratings by users: " + nf(r,0,1) + " / 10";
app.text(user4, 760,220);
int index4 = int(random(rev_film4.length)); // the random function of the comments
String user44 = "Reviews: " + "\n" + rev_film4[index4];
app.text(user44, 760,250);
}
public void windowClosing(GWindow w)
{
btn.setEnabled(false);
player.close();
minim.stop();
exit();
}
Please try to post a MCVE instead of your full program. For example, try creating a simple sketch that shows a circle every X seconds. That way we can focus on your problem instead of all the extra stuff that has nothing to do with your question.
But to answer your question, you can use the millis() function or the frameCount variable to check how much time has gone by, then do something every X seconds or every X frames.
Related posts:
How to make a delay in processing project?
How can I draw only every x frames?
Removing element from ArrayList every 500 frames
Timing based events in Processing
How to add +1 to variable every 10 seconds in Processing?
How to create something happen when time = x
making a “poke back” program in processing
Processing: How do i create an object every “x” time
Timer using frameRate and frame counter reliable?
Please also consult the Processing reference for more information.
If you still can't get it working, please post a MCVE (not your full project!) in a new question and we'll go from there. Good luck.

Using ACE with WT and highlighting lines. This is not working

This code is not working, I keep having a loading sign on top to the right but the editor works. Is it possible to have some help towards the actual connection from the Ace Editor file to the C++ WT file.
//Start.
editor1 = new Wt::WText(wt_root);
editor1->setText("Testing for the highlight.");
editor1->setInline(false);
//REQUIREMENT FOR THE ACEEDITOR FILE INPUTED.
Wt::WApplication::instance()->require(std::string("AceFiles/ace.js"));
//CONFIG FOR THE EDITOR THAT WILL SUPPORT TEXT.
editor = new Wt::WContainerWidget(wt_root);
editor->resize(500, 500);
range = new Wt::WContainerWidget(wt_root);
//editor_ref IS THE STRING THAT THE USER IS WRITTING.
std::string editor_ref = editor->jsRef();
std::string range_ref = range->jsRef();
std::string command =
editor_ref + ".editor = ace.edit(" + editor_ref + ");" +
range_ref + ".range = ace.require('ace/range')." + range_ref + ";" +
editor_ref + ".editor.setTheme(\"ace / theme / github\");" +
editor_ref + ".editor.getSession().setMode(\"ace/mode/assembly_x86\");" +
editor_ref + ".editor.session.addMarker(new Range(1, 0, 15, 0), \"fullLine\");";
editor->doJavaScript(command);
//CONFIG. FOR THE JSIGNAL USED.
//BEING THE CONNECTION BETWEEN THE C++ DOC AND THE JAVA SCRIPT.
jsignal = new Wt::JSignal<std::string>(editor, "textChanged");
jsignal->connect(this, &Ui_AceEditor::textChanged);
//CONFIG FOR THE BUTTON.
b = new Wt::WPushButton("Save", wt_root);
command = "function(object, event) {" +
jsignal->createCall(editor_ref + ".editor.getValue()") +
";}";
b->clicked().connect(command);

Change the font size in a text layer

I'm trying to create a script for Photoshop, but all my text gets the same size. I've created a small test script that shows my problem. Both layers get the same text size, and the size doesn't make sense.
var DPI = 300
$.writeln(DPI + " DPI **********************************");
//UnitValue.baseUnit = UnitValue(1/DPI, "in");
//$.writeln("baseUnit: " + UnitValue.baseUnit);
doc = app.documents.add(
200,
287,
DPI,
"Test");
var layer = doc.artLayers.add();
layer.kind = LayerKind.TEXT;
layer.textItem.font = "PalatinoLinotype-Roman";
layer.textItem.size = new UnitValue(3, "mm");
$.writeln("textItem.size: " + layer.textItem.size + " (" + layer.textItem.size.baseUnit + ")");
var layer2 = doc.artLayers.add();
layer2.kind = LayerKind.TEXT;
layer2.textItem.font = "PalatinoLinotype-Roman";
layer2.textItem.size = new UnitValue(120, "px");
$.writeln("textItem.size: " + layer2.textItem.size + " (" + layer2.textItem.size.baseUnit + ")");
This is what it looks like when I run it in the ExtendScript Toolkit:
I'm new to this, so am I missing something obvious?

Print a header on set page using Abc PDF

I have created pdf from HTML page using Abc PDF now my problem is I want to print a table header on next page, but only if table data is display within a another page, if not display header on a different page, any one have idea about how we can do this using Abc pdf.
What you need to do is create the page with some space at the top, then once your document is built in abc PDF loop though the pages and add a header.
The code below is what I use to add a header, the header in this case has three bits a image at the top and two boxes with text in.
Remember the cord in abc pdf are from the bottom right not the top left.
private static Doc AddHeader(Doc theDoc, Core.Property propertyDetails)
{
int theCount = theDoc.PageCount;
int i = 0;
//Image header
for (i = 1; i <= theCount; i++)
{
theDoc.Rect.Width = 590;
theDoc.Rect.Height = 140;
theDoc.Rect.Position(0, 712);
theDoc.PageNumber = i;
//Check Which office to use.
string imagefilePath = HttpContext.Current.Server.MapPath("/images/pdf/pdf-header.png");
Bitmap myBmp = (Bitmap)Bitmap.FromFile(imagefilePath);
theDoc.AddImage(myBmp);
}
//page header boxes.
//Grey header box
theDoc.Rect.String = "20 15 590 50";
theDoc.Rect.Position(13, 672);
System.Drawing.Color colour = System.Drawing.ColorTranslator.FromHtml("#CCCCCC");
theDoc.Color.Color = colour;
theDoc.PageNumber = 1;
theDoc.FillRect();
theDoc.Rect.String = "20 15 586 50";
theDoc.Rect.Position(30, 660);
System.Drawing.Color pageoneText = System.Drawing.ColorTranslator.FromHtml("#50474A");
theDoc.Color.Color = pageoneText;
string thePageFont = "Century Gothic";
theDoc.Font = theDoc.AddFont(thePageFont);
theDoc.FontSize = 16;
theDoc.PageNumber = 1;
theDoc.AddText("My Text!!!!!");
theDoc.Rect.String = "20 15 590 50";
theDoc.Rect.Position(13, 630);
System.Drawing.Color greyBox = System.Drawing.ColorTranslator.FromHtml("#468DCB");
theDoc.Color.Color = greyBox;
theDoc.PageNumber = 1;
theDoc.FillRect();
theDoc.Rect.String = "20 15 586 50";
theDoc.Rect.Position(30, 620);
System.Drawing.Color greyText = System.Drawing.ColorTranslator.FromHtml("#ffffff");
theDoc.Color.Color = greyText;
string thePageFontTwo = "Century Gothic";
theDoc.Font = theDoc.AddFont(thePageFontTwo);
theDoc.FontSize = 14;
theDoc.PageNumber = 1;
theDoc.AddText("This is more text");
return theDoc;
}
Then once the pdf file is created just call
var theDoc = new Doc();
/// Your document creation stuff!!!
theDoc = AddHeader(theDoc, propertyDetails);

Resources